<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表格</title>
    <script src="../js/vue.js"></script>
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <script src="../plugins/elementui/index.js"></script>

</head>
<body>
    <div id="app">
        <el-table :data="tableData" border style="width: 100%">
            <el-table-column prop="date" label="日期" width="180"></el-table-column>
            <el-table-column prop="name" label="姓名" width="180"></el-table-column>
            <el-table-column prop="address" label="地址"></el-table-column>
        </el-table>


        <!--分页功能-->
        <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage4"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="10"
                layout="total, sizes, prev, pager, next, jumper"
                :total="50">
        </el-pagination>
        <hr/>
        <!--消息提示-->
        <el-button :plain="true" @click="open1">消息</el-button>
        <el-button :plain="true" @click="open2">成功</el-button>
        <el-button :plain="true" @click="open3">警告</el-button>
        <el-button :plain="true" @click="open4">错误</el-button>
    </div>

    <script>
        var vue =new Vue({
            el:'#app',
            data:{
                total:0,
                currentPage4: 1,

                //声明变量的地方
                tableData:[]
            },
            created(){
                //vue初始化完成后执行
                this.tableData=[{
                    date: '2016-05-02',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1518 弄'
                }, {
                    date: '2016-05-04',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1517 弄'
                }, {
                    date: '2016-05-01',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1519 弄'
                }, {
                    date: '2016-05-03',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1516 弄'
                }];
                this.total=100;
            },
            mounted(){
                //挂载
            },
            methods:{
                //定义方法的地方
                open1() {
                    this.$message('这是一条消息提示');

                    /*var config={
                        message: '恭喜你，这是一条xxx消息',
                        type: 'success'
                    }
                    this.$message(config);*/
                },
                open2() {
                    this.$message({
                        message: '恭喜你，这是一条成功消息',
                        type: 'success'
                    });
                },

                open3() {
                    this.$message({
                        message: '警告哦，这是一条警告消息',
                        type: 'warning'
                    });
                },

                open4() {
                    this.$message.error('错了哦，这是一条错误消息');
                },

                handleSizeChange(val) {
                    console.log(`每页 ${val} 条`);
                },

                handleCurrentChange(val) {
                    console.log(`当前页: ${val}`);
                }

            }
        });
    </script>
</body>
</html>